'use strict';
module.exports = {
	/**
	 * XXXnameXXX
	 * @url client/history/kh/vip_history 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let {
			data = {}, userInfo, util, filterResponse, originalParam
		} = event;
		let {
			customUtil,
			uniID,
			config,
			pubFun,
			vk,
			db,
			_
		} = util;
		let {
			uid,
			appid,
			appname,
			tv_name,
			tv_id,
			series,
			series_id,
			tv_image,
			_add_time,
			_add_time_str
		} =
		data;
		let res = {
			code: 0,
			msg: ""
		};
		// 业务逻辑开始-----------------------------------------------------------

		// 参数验证结束
		let dbName = "a_vip_history"; // 表名

		// 执行 数据库add 命令
		res.id = await vk.baseDao.add({
			dbName,
			dataJson: {
				user_id: userInfo._id,
				nickname: userInfo.nickname,
				appid: userInfo.appid,
				appname: userInfo.appname,
				tv_name,
				is_follow: false,
				plus_type: userInfo.plus_type,
				os_name: originalParam.context.osName || "未知", //用户看剧时的系统
				tfid: userInfo.tfid,
				invite_code: userInfo.invite_code,
				middleman_id: userInfo.middleman_id,
				tv_id,
				series,
				series_id,
				tv_image,
				_add_time,
				_add_time_str
			}
		});
		let info = await vk.baseDao.findByWhereJson({
			dbName: "a_appid",
			whereJson: {
				appid:userInfo.appid,
			}
		});

       res.simplified=info.simplified



		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}